﻿using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Sys;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Sys;

namespace VisionCloud.Api.Controllers.Sys
{
    /// <summary>
    /// 菜单内部功能控制器
    /// </summary>
    [SystemModule("菜单内部功能控制器")]
    [ApiAuthorize(PolicyEnum.RequireRolePermission)]
    [ApiVersion("1.0")]
    [Route("api/sys/[controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "菜单内部功能控制器")]
    public class MenuFuncController : ApiBaseController
    {
        /// <summary>
        /// 菜单功能服务
        /// </summary>
        public MenuFuncService MenuFuncService { get; set; }

        #region 菜单功能

        /// <summary>
        /// 创建菜单功能
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> CreateMenuFunc(SysMenuFuncDto model)
        {
            return await TryCatchAsync(MenuFuncService.CreateMenuFunc(model, TokenModel.YunUserGuid));
        }

        /// <summary>
        /// 编辑菜单功能
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> EditMenuFunc(SysMenuFuncDto model)
        {
            return await TryCatchAsync(MenuFuncService.UpdateMenuFunc(model, TokenModel.YunUserGuid));
        }

        /// <summary>
        /// 删除菜单功能
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> DeleteMenuFunc(SysMenuFuncDto model)
        {
            return await TryCatchAsync(MenuFuncService.DeleteMenuFunc(model.MenuFuncId, TokenModel.YunUserGuid));
        }

        /// <summary>
        /// 获取菜单功能列表
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> GetMenuFuncList(SysMenuFuncCondition condition)
        {
            return await TryCatchAsync(MenuFuncService.GetMenuFuncPage(condition));
        }

        #endregion 菜单功能
    }
}